<template>
  <div id="cluereport">
    <el-dialog
      :title="'被授权用户：'+username(roleuser[1])"
      :visible.sync="setrole0"
      width="50%" :close-on-click-modal="false" :close-on-press-escape="false">
      <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
      <div style="margin: 15px 0;"></div>
      <el-checkbox-group v-model="role" @change="handleCheckedChange" style="margin-left:20px">
        <el-checkbox v-for="(item,index) in roles" :label="item" :key="index">{{item}}</el-checkbox>
      </el-checkbox-group>
      <el-button type="primary" @click="submitRoles" style="margin-top:30px;" :loading="roleSubmitLoading">提交</el-button>
    </el-dialog>
    <el-drawer :visible.sync="drawer" ref="drawer" :with-header="false" size="50%">
      <h1>被授权用户：{{username(roleuser[1])+setAuthText}}</h1>
      <div style="padding:20px;">
        <el-form :inline="true" :model="roleForm">
          <el-form-item>
            <el-checkbox :indeterminate="isIndeterminate2" v-model="checkAll2" @change="handleCheckAllChange2" style="font-weight:bolder">全选</el-checkbox>
          </el-form-item>
          <div style="clear:both"></div>
          <el-form-item>
            <el-checkbox v-model="roleForm.dw" @change="roles2change">单位</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.bm" @change="roles2change">部门</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.xm" @change="roles2change">姓名</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.idcardno" @change="roles2change">身份证号</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.xb" @change="roles2change">性别</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.zw" @change="roles2change">职务</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.zwcc" @change="roles2change">职务层次</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.zywgwjwtzy" @change="roles2change">主要违规违纪问题摘要</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.wtly" @change="roles2change">问题来源</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.wtrd" @change="roles2change">问题认定</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.lasj" @change="roles2change">立案时间</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.lajdjg" @change="roles2change">立案决定机关</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.cllx" @change="roles2change">处理处分类型</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.cljdjg" @change="roles2change">处理处分类型详情</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.clnr" @change="roles2change">处理处分内容</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.clzxqk" @change="roles2change">处理处分执行情况</el-checkbox>
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="roleForm.remark" @change="roles2change">备注</el-checkbox>
          </el-form-item>
          <div style="clear:both"></div>
          <el-form-item>
            <el-button type="primary" @click="submitRoles2" :loading="roleSubmitLoading2">提交</el-button>
            <el-button type="danger" @click="removeAuth" :loading="roleSubmitLoading2" v-show="settype===1">取消授权</el-button>
            <el-button @click="$refs.drawer.closeDrawer()" style="color:#000 !important">取消</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-drawer>
    <el-dialog
      :title="dialogtitle"
      :visible.sync="dialogVisible"
      width="98%" top="20px" :close-on-click-modal="false" :close-on-press-escape="false">
      <cadreHandlingEdit @dialogHide="dialogHide($event)" :data="item" :readOnly="readonly" :timestamp="timestamp" :listdics="listdics"></cadreHandlingEdit>
    </el-dialog>
    <el-dialog
      title="导出报表"
      :visible.sync="exportDialogVisible"
      width="98%" top="20px" :close-on-click-modal="false" :close-on-press-escape="false">
      <el-form :model="exportForm" label-width="150px" ref="exportForm">
        <fieldset>
          <legend>筛选条件</legend>
          <el-form-item label="处理处分年度" prop="years">
            <el-checkbox-group v-model="exportForm.years">
              <el-checkbox v-for="(item, index) in yearList" :key="index" :label="item" style="margin-right:30px">{{item}}年</el-checkbox>
            </el-checkbox-group>
          </el-form-item>
          <el-form-item label="处理处分决定机关" prop="cljdjg">
            <el-checkbox :indeterminate="isIndeterminateCljdjgs" v-model="checkAllCljdjgs" @change="handleCheckAllCljdjgsChange">全选</el-checkbox>
            <el-checkbox-group v-model="exportForm.cljdjg" @change="changeCljdjgs">
              <el-checkbox v-for="(item, index) in cljdjgDic" :key="index" :label="item.value" style="margin-right:30px">{{item.label}}</el-checkbox>
            </el-checkbox-group>
          </el-form-item>
          <el-form-item label="处理处分类型" prop="cllx">
            <el-checkbox :indeterminate="isIndeterminateCllx" v-model="checkAllCllx" @change="handleCheckAllCllxChange">全选</el-checkbox>
            <el-checkbox-group v-model="exportForm.cllx" @change="changeCllx">
              <div v-for="(item,index) in cllxDic" :key="index">
                <div style="width:150px;font-size:var(--size14) !important;display:block;float:left;text-align:right;padding-right:20px;font-weight:bolder">{{item.label}}</div>
                <el-checkbox v-for="it in item.children" :key="it.value" :label="it.value">{{it.label}}</el-checkbox>
                <el-checkbox v-show="item.value==='0905'" key="0905" label="0905" style="margin-right:30px">其他</el-checkbox>
              </div>
              <el-checkbox key="null" :label="null" style="margin-left:170px">无处理处分</el-checkbox>
            </el-checkbox-group>
          </el-form-item>
        </fieldset>
        <el-form-item label="报表输出字段" prop="columns">
          <el-checkbox :indeterminate="isIndeterminateColumns" v-model="checkAllColumns" @change="handleCheckAllColumnsChange">全选</el-checkbox>
          <el-checkbox-group v-model="exportForm.columns" @change="changeColumns">
            <el-checkbox v-for="(item,index) in allColumns" :key="index" :label="item.value">{{item.label}}</el-checkbox>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item>
          <el-button  type="primary" @click="exportChart2" :loading="exportLoading1" icon="el-icon-tickets" >导出报表</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
    <el-breadcrumb separator=">">
      <el-breadcrumb-item :to="{ path: '/' }">系统首页</el-breadcrumb-item>
      <el-breadcrumb-item>干部监督</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/cadrehandling' }">干部处理</el-breadcrumb-item>
    </el-breadcrumb>
    <section class="wboxs">
    <!--工具条-->
      <h1>干部处理</h1>
      <el-form :inline="true" :model="filters" v-if="roleShow">
        <div style="padding:22px 22px 0;" v-if="!moreshow">
          <el-form-item label="姓名" label-width="50px">
            <el-input v-model="filters.xm" style="width:100px;" placeholder="关键字"></el-input>
          </el-form-item>
          <el-form-item label="单位" label-width="50px">
            <el-autocomplete v-model="filters.dw" style="width:280px;" :fetch-suggestions="querySearch" placeholder="请输入单位名称关键字" :trigger-on-focus="false" ></el-autocomplete>
          </el-form-item>
          <el-form-item label="问题来源" label-width="80px">
            <el-select v-model="filters.wtly" placeholder="请选择" style="width:150px;">
              <el-option label="全部" value=""></el-option>
              <el-option v-for="(item, index) in wtlyDic" :key="index" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-tooltip class="item" effect="dark" content="查询" placement="top">
              <el-button type="primary" circle @click="search" icon="el-icon-search"></el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="新增干部处理信息" placement="top" v-if="roleEdit">
              <el-button type="success" circle @click="addnew(false,{})" icon="el-icon-circle-plus-outline" ></el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="展开更多" placement="top">
              <el-button circle @click="changeMoreShow(true)" icon="el-icon-more" style="color:#000 !important"></el-button>
            </el-tooltip>
          </el-form-item>
        </div>
        <div style="padding:22px 22px 0;" v-else>
          <el-form-item style="float:right;width:180px;">
            <el-tooltip class="item" effect="dark" content="分析图表" placement="top" v-if="roleChart">
              <el-button type="success" circle icon="el-icon-data-line" @click="showchart"></el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="操作日志" placement="top" v-if="roleAdmin">
              <el-button type="info" circle icon="el-icon-edit-outline" @click="showlog" ></el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" :content="authFlag?'切换到编辑模式':'切换到授权模式'" placement="top" v-if="roleAdmin">
              <el-button :type="authFlag?'warning':''" circle icon="el-icon-user" @click="changeAuthFlag" :style="authFlag?'':'color:#000 !important'"></el-button>
            </el-tooltip>
            <div style="margin-top:22px;text-align:right;" v-show="authFlag">
              <el-cascader @change="setRoleType" v-model="roleuser" :options="userlist" style="width:148px;" :show-all-levels="false"></el-cascader>
            </div>
          </el-form-item>
          <el-form-item label="姓名" label-width="120px">
            <el-input v-model="filters.xm" style="width:100px;" placeholder="关键字"></el-input>
          </el-form-item>
          <el-form-item label="单位" label-width="50px">
            <el-autocomplete v-model="filters.dw" style="width:280px;" :fetch-suggestions="querySearch" placeholder="请输入单位名称关键字" :trigger-on-focus="false" ></el-autocomplete>
          </el-form-item>
          <el-form-item label="问题来源" label-width="80px">
            <el-select v-model="filters.wtly" placeholder="请选择" style="width:150px;">
              <el-option label="全部" value=""></el-option>
              <el-option v-for="(item, index) in wtlyDic" :key="index" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item><br>
          <el-form-item label="处理处分类型" label-width="120px">
            <el-cascader v-model="filters.cllx" :options="cllxDic" :props="{ checkStrictly: true }"></el-cascader>
          </el-form-item>
          <!-- <el-form-item label="处理决定机关">
            <el-select v-model="filters.cljdjg" placeholder="请选择" style="width:100px;">
              <el-option label="全部" value=""></el-option>
              <el-option v-for="(item, index) in cljdjgDic" :key="index" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="处理决定时间">
            <el-date-picker
              style="width:307px;"
              v-model="filters.cljdsj"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd"
              >
            </el-date-picker>
          </el-form-item>
          <el-form-item label="影响期">
            <el-select v-model="filters.yxq" placeholder="请选择" style="width:100px;">
              <el-option label="全部" value=""></el-option>
              <el-option v-for="(item, index) in yxqDic" :key="index" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item> -->
          <el-form-item>
            <el-tooltip class="item" effect="dark" content="查询" placement="top">
              <el-button type="primary" circle @click="search" icon="el-icon-search"></el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="根据查询结果导出台帐表" placement="top" v-if="roleAdmin||roleExport">
              <el-button type="info" circle @click="exportChart1" icon="el-icon-tickets" ></el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="定制报表导出" placement="top" v-if="roleAdmin||roleExport">
              <el-button type="warning" circle @click="showExportDialog()" icon="el-icon-collection" ></el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="新增干部处理信息" placement="top" v-if="roleEdit">
              <el-button type="success" circle @click="addnew(false,{})" icon="el-icon-circle-plus-outline" ></el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="隐藏更多" placement="top">
              <el-button type="info" circle @click="changeMoreShow(false)" icon="el-icon-more"></el-button>
            </el-tooltip>
          </el-form-item>
        </div>
      </el-form>
      <div v-else :style="'color:red;font-weight:bolder;height:'+(tableHeight+150)+'px;padding:25px;font-size:var(--size20) !important'" >当前模块未授权</div>
    </section>
    <section class="wboxd" style="margin-top:10px" v-if="roleShow">
      <!--列表-->
      <el-table :data="list" highlight-current-row v-loading="listLoading" style="width: 100%;" @sort-change='sortChange' :height="tableHeight" border
        @selection-change="handleSelectionChange"
        ref="multipleTable"
        >
        <el-table-column type="index" label="序号" width="50" fixed align="center" class-name="tableth">
        </el-table-column>
        <el-table-column type="selection" width="45" fixed>
        </el-table-column>
        <el-table-column prop="xm" label="姓名" width="80" sortable="custom" align="center">
        </el-table-column>
        <el-table-column prop="xb" label="性别" width="80" sortable="custom" align="center">
        </el-table-column>
        <el-table-column prop="dw" label="单位" sortable="custom" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="zw" label="职务" width="120" sortable="custom" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="zwcc" label="职务层次" width="110" sortable="custom" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="wtly" label="问题来源" width="130" sortable="custom" show-overflow-tooltip>
          <template slot-scope="scope">
            {{scope.row.wtlyText}}<span v-if="scope.row.wtlyText==='其他'">：{{scope.row.qtwtly}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="cllx" label="处理处分类型" width="200" sortable="custom" show-overflow-tooltip>
          <template slot-scope="scope" v-if="scope.row.cllx">
            <el-popover placement="top-start" width="400" trigger="hover" v-if="scope.row.cllx&&scope.row.cllx.split(',').length>1">
              <div v-for="(item,index) in cllxDic" :key="index" style="clear:both">
                <div v-if="scope.row.cllx&&scope.row.cllx!==''&&scope.row.cllx.indexOf(item.value)>-1">
                  <div style="font-size:var(--size14) !important;float:left;font-weight:bolder">{{item.label}}：</div>
                  <div style="font-size:var(--size14) !important;float:left;padding-left:10px" v-for="(it,idx) in item.children" :key="idx" v-show="scope.row.cllx.split(',').indexOf(it.value)>-1">{{it.label}}</div>
                  <!-- <div style="font-size:var(--size14) !important;float:left;" v-if="item.value==='0901'&&scope.row.cllx.split(',').indexOf('090105')>-1">（{{JSON.parse(scope.row.qtcllx)['090105']}}）</div>
                  <div style="font-size:var(--size14) !important;float:left;" v-if="item.value==='0902'&&scope.row.cllx.split(',').indexOf('090206')>-1">（{{JSON.parse(scope.row.qtcllx)['090206']}}）</div> -->
                  <div style="font-size:var(--size14) !important;float:left;" v-if="item.value==='0905'&&scope.row.cllx.split(',').indexOf('0905')>-1">（{{JSON.parse(scope.row.qtcllx)['0905']}}）</div>
                </div>
              </div>
              <span slot="reference">{{cllxCode2Name(scope.row.cllx.split(","))}}...</span>
            </el-popover>
            <span v-else>{{cllxCode2Name(scope.row.cllx.split(","))}}</span>
          </template>
        </el-table-column>
        <!-- <el-table-column prop="cljdjg" label="处理决定机关" width="140" sortable="custom" align="center">
          <template slot-scope="scope">
            {{scope.row.cljdjgText}}<span v-if="scope.row.cljdjgText==='其他'">：{{scope.row.qtcljdjg}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="cljdsj" label="处理决定时间" width="140" sortable="custom" align="center">
        </el-table-column>
        <el-table-column prop="yxq" label="影响期" width="90" sortable="custom" align="center">
          <template slot-scope="scope">
            {{scope.row.yxqText}}<span v-if="scope.row.yxqText==='其他'">：{{scope.row.qtyxq}}</span>
          </template>
        </el-table-column> -->
        <el-table-column label="操作" width="220">
          <template slot-scope="scope">
            <el-button @click="detail(scope.row)" style="color:#000 !important;margin:10px 0" size="mini">查看</el-button>
            <el-button v-if="roleEdit" @click="edit(scope.row)" type="primary" size="mini" style="margin:10px 0 10px 5px" v-show="!authFlag">编辑</el-button>
            <el-button @click="setAuth(scope.row.id)" type="warning" size="mini" style="margin:10px 0 10px 5px" v-show="authFlag" :disabled="!setRole">授权</el-button>
            <el-dropdown v-if="roleEdit" style="margin-left:5px">
              <span class="el-dropdown-link" style="cursor: pointer;color: #409eff;font-weight:bolder">
                更多<i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item @click.native="del(scope.row.id)">删除</el-dropdown-item>
                <!-- <el-dropdown-item>授权</el-dropdown-item> -->
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
      </el-table>
      <div class="block" v-if="roleShow">
        <!-- <el-button type="danger" @click="dels" style="float:left;margin:5px 20px;" v-show="!authFlag" v-if="roleEdit">批量删除</el-button> -->
        <el-button type="warning" @click="setAuth()" style="float:left;margin:5px 20px;" v-show="authFlag" :disabled="!setRole">批量授权</el-button>
        <div style="line-height:48px;float:left;padding-left:20px">注：<span style="font-family:'宋体';font-size:14px;">***</span> 为未授权信息</div>
        <el-pagination style="float:right" :total="totalnum" :page-size="pageSize" @current-change="handleCurrentChange" :current-page="pageNum" @size-change="handleSizeChange" :page-sizes="[10, 20, 30, 50]" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
      </div>
    </section>
  </div>
</template>

<script>
import cadreHandlingEdit from './edit'
export default {
  components: {
    cadreHandlingEdit
  },
  data () {
    return {
      listdics: {},
      myyear: 0,
      allColumns: [
        {value: 'xm', label: '姓名', checked: true},
        {value: 'xb', label: '性别', checked: true},
        {value: 'idcardno', label: '身份证号', checked: false},
        {value: 'dw', label: '单位', checked: true},
        {value: 'bm', label: '部门', checked: false},
        {value: 'zw', label: '职务', checked: true},
        {value: 'zwcc', label: '职务层次', checked: false},
        {value: 'zywgwjwtzy', label: '主要违规违纪问题摘要', checked: true},
        {value: 'wtly', label: '问题来源', checked: true},
        {value: 'wtrd', label: '问题认定', checked: false},
        {value: 'lasj', label: '立案时间', checked: false},
        {value: 'lajdjg', label: '立案决定机关', checked: false},
        {value: 'cllx', label: '处理处分类型', checked: true},
        {value: 'cllx2', label: '处理处分类型明细', checked: false},
        {value: 'cljdjg', label: '处理处分决定机关', checked: true},
        {value: 'cljdsj', label: '处理处分决定时间', checked: true},
        {value: 'yxq', label: '影响期', checked: true},
        {value: 'jdws', label: '决定文书', checked: true},
        {value: 'clnr', label: '处理处分内容', checked: false},
        {value: 'clzxqk', label: '处理处分执行情况', checked: false},
        {value: 'remark', label: '备注', checked: false}
      ],
      isIndeterminateColumns: true,
      checkAllColumns: false,
      isIndeterminateCllx: false,
      checkAllCllx: true,
      isIndeterminateCljdjgs: false,
      checkAllCljdjgs: true,
      yearList: [],
      exportDialogVisible: false,
      exportForm: {
        years: [],
        cljdjg: [],
        cllx: [],
        columns: []
      },
      moreshow: false,
      exportLoading1: false,
      cllxDic: [],
      wtlyDic: [],
      cljdjgDic: [],
      yxqDic: [],
      roleShow: true,
      roleAdmin: true,
      roleEdit: true,
      roleChart: true,
      roleExport: true,
      settype: '',
      userRoles: [],
      setAuthText: '',
      roleSubmitLoading2: false,
      isIndeterminate2: false,
      roleSubmitLoading: false,
      role: [],
      checkAll2: false,
      checkAll: false,
      isIndeterminate: false,
      setRole: false,
      setrole0: false,
      // roles: [{label: '查看', value: 1}, {label: '编辑', value: 2}, {label: '分析', value: 3}],
      roles: ['查看', '编辑', '分析', '报表导出'],
      roles2: [],
      roleuser: [],
      userlist: [],
      processId: '',
      roleForm: {
        id: '',
        processId: '',
        authUserId: '',
        dw: false,
        bm: false,
        xm: false,
        idcardno: false,
        xb: false,
        zw: false,
        zwcc: false,
        zywgwjwtzy: false,
        wtly: false,
        qtwtly: false,
        wtrd: false,
        lasj: false,
        lajdjg: false,
        cllx: false,
        qtcllx: false,
        clnr: false,
        cljdjg: false,
        cljdjg2: false,
        cljdjg3: false,
        cljdjg4: false,
        cljdjg5: false,
        cljdjg6: false,
        qtcljdjg: false,
        qtcljdjg2: false,
        qtcljdjg3: false,
        qtcljdjg4: false,
        qtcljdjg5: false,
        qtcljdjg6: false,
        cljdsj: false,
        cljdsj2: false,
        cljdsj3: false,
        cljdsj4: false,
        cljdsj5: false,
        cljdsj6: false,
        yxq: false,
        yxq2: false,
        yxq3: false,
        yxq4: false,
        yxq5: false,
        yxq6: false,
        qtyxq: false,
        qtyxq2: false,
        qtyxq3: false,
        qtyxq4: false,
        qtyxq5: false,
        qtyxq6: false,
        jdws: false,
        jdws2: false,
        jdws3: false,
        jdws4: false,
        jdws5: false,
        jdws6: false,
        clzxqk: false,
        remark: false
      },
      drawer: false,
      authUser: '',
      authFlag: false,
      timestamp: '',
      noRoleCode: '***',
      noRoleText: '***',
      filters: {
        xm: '',
        dw: '',
        wtly: '',
        cllx: [],
        cljdjg: '',
        cljdsj: [],
        yxq: ''
      },
      listLoading: false,
      ids: [],
      tableHeight: 100,
      list: [],
      pageNum: 1,
      pageSize: 20,
      totalnum: 0,
      item: {},
      dialogtitle: '新增干部处理',
      dialogVisible: false,
      readonly: false,
      testAddFormLoading: false,
      testAddForm: {
        UserName: '',
        PassWord: '',
        TrueName: '',
        UnitName: '',
        Enable: '停用'
      },
      total: 0,
      Isace: 'asc',
      Sortkey: '',
      changeSizeFlag: false,
      myloading: false,
      userRoles0: '' // 举报管理员权限
    }
  },
  methods: {
    showExportDialog () {
      this.getYearList()
      this.exportDialogVisible = true
      this.exportForm.years = [this.myyear]
      this.exportForm.cljdjg = this.cljdjgDic.map(item => item.value)

      let allCllx = []
      this.cllxDic.forEach(item => {
        if (item.children) {
          allCllx.push(...item.children.map(it => it.value))
        } else {
          allCllx.push(item.value)
        }
      })
      allCllx.push(null)
      this.exportForm.cllx = allCllx
      this.exportForm.columns = this.allColumns.filter(item => item.checked).map(item => item.value)
    },
    exportChart2 () {
      if (!this.exportForm.years || this.exportForm.years.length === 0) {
        this.$message({
          message: '请选择年度',
          type: 'error'
        })
        return false
      }
      if (!this.exportForm.cljdjg || this.exportForm.cljdjg.length === 0) {
        this.$message({
          message: '请选择处理决定机关',
          type: 'error'
        })
        return false
      }
      if (!this.exportForm.cllx || this.exportForm.cllx.length === 0) {
        this.$message({
          message: '请选择处理处分类型',
          type: 'error'
        })
        return false
      }
      if (!this.exportForm.columns || this.exportForm.columns.length === 0) {
        this.$message({
          message: '请选择输出字段',
          type: 'error'
        })
        return false
      }
      let title = ''
      if (this.exportForm.years.length === 1) {
        title = this.exportForm.years[0] + '年度'
      } else if (this.exportForm.years.length > 1 && this.exportForm.years.length < this.yearList.length) {
        // 排序
        let selectYears = []
        this.yearList.forEach(item => {
          if (this.exportForm.years.indexOf(item) > -1) {
            selectYears.push(item)
          }
        })
        title = selectYears.join('、') + '年度'
      }
      if (this.exportForm.cljdjg.length === 1) {
        title = title + this.cljdjgDic.find(item => item.value === this.exportForm.cljdjg[0]).label + '办理的'
      } else if (this.exportForm.cljdjg.length > 1 && this.exportForm.cljdjg.length < this.cljdjgDic.length) {
        // 排序
        let selectCljdjg = []
        this.cljdjgDic.forEach(item => {
          if (this.exportForm.cljdjg.indexOf(item.value) > -1) {
            selectCljdjg.push(item.value)
          }
        })
        title = title + selectCljdjg.map(it => this.cljdjgDic.find(item => item.value === it).label).join('、')
      }
      let allCllx = []
      this.cllxDic.forEach(item => {
        if (item.children) {
          allCllx.push(...item.children.map(it => {
            return {label: it.label, value: it.value}
          }))
        } else {
          allCllx.push({label: item.label, value: item.value})
        }
      })
      allCllx.push({value: null, label: '无处理处分'})
      console.log(allCllx)
      if (this.exportForm.cllx.length === 1) {
        title = title + allCllx.find(item => item.value === this.exportForm.cllx[0]).label
      } else if (this.exportForm.cllx.length > 1 && this.exportForm.cllx.length < allCllx.length) {
        // 排序
        let selectCllx = []
        allCllx.forEach(item => {
          if (this.exportForm.cllx.indexOf(item.value) > -1) {
            selectCllx.push(item.value)
          }
        })
        title = title + selectCllx.map(it => allCllx.find(item => item.value === it).label).join('、')
      } else {
        title = title + '处理处分'
      }
      title = title + '人员名单'
      let selectColumns = []
      this.allColumns.forEach(item => {
        if (this.exportForm.columns.indexOf(item.value) > -1) {
          selectColumns.push(item.value)
        }
      })
      let para = {
        cljdjg: this.exportForm.cljdjg,
        cllx: this.exportForm.cllx,
        fields: selectColumns,
        fileName: '定制导出干部处理报表',
        nd: this.exportForm.years,
        title: title
      }
      this.exportLoading1 = true
      // var personParams = { Page: 0, Pagenum: 20, Personname: '', Unitkey: '', Sortkey: '', Isace: true, timestamp: new Date().getTime() }
      this.$http
        .post(this.$http.defaults.selectionAPI + `api/busClueReportProcess/exportProcessCustom`, para)
        .then(response => {
          if (response.data.success) {
            this.download(response.data.result)
            this.exportLoading1 = false
          } else {
            this.$message({
              message: '导出失败:' + response.data.message,
              type: 'error'
            })
          }
        })
        .catch(error => {
          this.$message({
            message: '网络导出失败:' + error,
            type: 'error'
          })
        })
    },
    handleCheckAllCljdjgsChange (val) {
      this.exportForm.cljdjg = val ? this.cljdjgDic.map(item => item.value) : []
      this.isIndeterminateCljdjgs = false
    },
    changeCljdjgs (val) {
      let checkedCount = val.length
      this.checkAllCljdjgs = checkedCount === this.cljdjgDic.length
      this.isIndeterminateCljdjgs = checkedCount > 0 && checkedCount < this.cljdjgDic.length
    },
    handleCheckAllCllxChange (val) {
      let allCllx = []
      this.cllxDic.forEach(item => {
        if (item.children) {
          allCllx.push(...item.children.map(it => it.value))
        } else {
          allCllx.push(item.value)
        }
      })
      allCllx.push(null)
      this.exportForm.cllx = val ? allCllx : []
      this.isIndeterminateCllx = false
    },
    changeCllx (val) {
      let allCllx = []
      this.cllxDic.forEach(item => {
        if (item.children) {
          allCllx.push(...item.children.map(it => it.value))
        } else {
          allCllx.push(item.value)
        }
      })
      allCllx.push(null)
      let checkedCount = val.length
      this.checkAllCllx = checkedCount === allCllx.length
      this.isIndeterminateCllx = checkedCount > 0 && checkedCount < allCllx.length
    },
    handleCheckAllColumnsChange (val) {
      this.exportForm.columns = val ? this.allColumns.map(item => item.value) : []
      this.isIndeterminateColumns = false
    },
    changeColumns (val) {
      if (val.indexOf('cllx') === -1 && (val.indexOf('cllx2') > -1 || val.indexOf('cljdjg') > -1 || val.indexOf('cljdsj') > -1 || val.indexOf('yxq') > -1 || val.indexOf('jdws') > -1)) {
        val.push('cllx')

        this.$message({
          message: '选择“处理处分类型明细”或“处理处分决定机关”或“处理处分决定时间”或“影响期”或“决定文书”其中一项时，必须选择“处理处分类型”',
          type: 'danger'
        })
      }
      let checkedCount = val.length
      this.checkAllColumns = checkedCount === this.allColumns.length
      this.isIndeterminateColumns = checkedCount > 0 && checkedCount < this.allColumns.length
    },
    getYearList () {
      this.$http
        .get(this.$http.defaults.selectionAPI + `api/busClueReportProcess/statProcessYears`)
        .then(response => {
          if (response.data.success) {
            this.yearList = response.data.result
          } else {
            this.$message({
              message: '获取失败:' + response.data.message,
              type: 'error'
            })
          }
        })
        .catch(error => {
          console.log(error)
          this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
        })
    },
    inRoles (str) {
      let arr = this.userRoles0
      // arr = 'aaabbROLE_admin'
      if (arr.indexOf(str) === -1) {
        return false
      } else {
        return true
      }
    },
    changeMoreShow (flag) {
      this.moreshow = flag
      if (!flag) {
        this.authFlag = false
      }
      this.tableresize(this)
    },
    cllxCode2Name (codeArr) {
      if (codeArr && codeArr.length > 0) {
        for (let i = 0; i < codeArr.length; i++) {
          for (let item of this.cllxDic) {
            let cllxName = ''
            if (codeArr[i] && codeArr[i] !== '' && codeArr[i].indexOf(item.value) > -1) {
              cllxName = item.label + ':'
              if (item.children) {
                for (let it of item.children) {
                  if (codeArr[i].indexOf(it.value) > -1) { cllxName += it.label }
                }
              }
            }
            if (cllxName !== '') {
              return cllxName
            }
          }
        }
      }
    },
    download (fileid) {
      var downloadElement = document.createElement('a')
      downloadElement.href = this.$http.defaults.baseURL + this.$http.defaults.selectionAPI + 'api/gen/file/download?id=' + fileid
      document.body.appendChild(downloadElement)
      downloadElement.click() // 点击下载
      document.body.removeChild(downloadElement) // 下载完成移除元素
    },
    exportChart1 () {
      let para = {
        xm: this.filters.xm,
        dw: this.filters.dw,
        wtly: this.filters.wtly && this.filters.wtly !== '' ? this.filters.wtly : null,
        cllx: this.filters.cllx && this.filters.cllx.length > 0 ? this.filters.cllx[this.filters.cllx.length - 1] : null,
        cljdjg: this.filters.cljdjg && this.filters.cljdjg !== '' ? this.filters.cljdjg : null,
        cljdsj: this.filters.cljdsj ? this.filters.cljdsj[0] : null,
        cljdsj2: this.filters.cljdsj ? this.filters.cljdsj[1] : null,
        yxq: this.filters.yxq && this.filters.yxq !== '' ? this.filters.yxq : null,
        pageNum: this.pageNum,
        pageSize: this.pageSize,
        sortField: this.Sortkey,
        sortOrder: this.Isace
      }
      this.exportLoading1 = true
      // var personParams = { Page: 0, Pagenum: 20, Personname: '', Unitkey: '', Sortkey: '', Isace: true, timestamp: new Date().getTime() }
      this.$http
        .post(this.$http.defaults.selectionAPI + `api/busClueReportProcess/exportProcess`, para)
        .then(response => {
          if (response.data.success) {
            this.download(response.data.result)
            this.exportLoading1 = false
          } else {
            this.$message({
              message: '导出失败:' + response.data.message,
              type: 'error'
            })
          }
        })
        .catch(error => {
          this.$message({
            message: '网络导出失败:' + error,
            type: 'error'
          })
        })
    },
    getDics (code) {
      this.$http
        .get(this.$http.defaults.selectionAPI + `api/sysDict/getByCode?code=` + code)
        .then(response => {
          if (response.data.success) {
            switch (code) {
              case '08':
                this.wtlyDic = response.data.result
                this.listdics.wtlyDic = this.wtlyDic
                break
              case '09':
                this.cllxDic = response.data.result
                this.listdics.cllxDic = this.cllxDic
                // this.cllxDic.unshift({value: null, label: '全部'})
                break
              case '10':
                this.cljdjgDic = response.data.result
                this.listdics.cljdjgDic = this.cljdjgDic
                break
              case '11':
                this.yxqDic = response.data.result
                this.listdics.yxqDic = this.yxqDic
                break
              case '17':
                this.cljdjgDic2 = response.data.result
                this.listdics.cljdjgDic2 = this.cljdjgDic2
                break
            }
          } else {
            this.$message({
              message: '获取失败:' + response.data.message,
              type: 'error'
            })
          }
        })
        .catch(error => {
          console.log(error)
          this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
        })
    },
    getAllDics () {
      this.getDics('08')
      this.getDics('09')
      this.getDics('10')
      this.getDics('11')
      this.getDics('17')
    },
    showchart () {
      this.$router.push('/cadrehandling/chart')
    },
    showlog () {
      this.$router.push('/cadrehandling/log')
    },
    geCurrUserRole () {
      this.$http.get(this.$http.defaults.selectionAPI + `api/busClueReportFuncAuth/geCurrUserFuncList2`).then(response => {
        if (response.data.success) {
          this.roleShow = response.data.result.roleShow
          this.roleEdit = response.data.result.roleEdit
          this.roleChart = response.data.result.roleChart
          this.roleExport = response.data.result.roleExport
          if (this.roleEdit) {
            this.roleShow = true
          }
          if (this.roleChart) {
            this.roleShow = true
          }
          if (this.roleExport) {
            this.roleShow = true
          }
          if (!this.roleShow && !this.roleEdit && !this.roleChart && !this.roleExport) {
            this.getCurrUserDataRole()
          }
        } else {
          console.log('获取失败:' + response.data.message)
          this.$message({
            message: '获取失败:' + response.data.message,
            type: 'error'
          })
        }
      })
    },
    getCurrUserDataRole () {
      this.$http.get(this.$http.defaults.selectionAPI + `api/busClueReportFuncAuth/getCurrentUserHasAuth2`).then(response => {
        if (response.data.success) {
          this.roleShow = response.data.result
        } else {
          console.log('获取失败:' + response.data.message)
          this.$message({
            message: '获取失败:' + response.data.message,
            type: 'error'
          })
        }
      })
    },
    handleCheckAllChange2 (val) {
      this.roles2 = []
      for (let item in this.roleForm) {
        if (item !== 'id' && item !== 'processId' && item !== 'authUserId') {
          this.roles2.push(item)
        }
      }
      console.log(this.roles2)
      this.selected = val ? this.roles2 : []
      for (let item in this.roleForm) {
        if (item !== 'id' && item !== 'processId' && item !== 'authUserId') {
          if (this.selected.indexOf(item) > -1) {
            this.roleForm[item] = true
          } else {
            this.roleForm[item] = false
          }
        }
      }
      this.isIndeterminate2 = false
    },
    roles2change () {
      this.selected = []
      this.roleForm.qtwtly = this.roleForm.wtly
      this.roleForm.qtcllx = this.roleForm.cllx
      this.roleForm.cljdjg2 = this.roleForm.cljdjg
      this.roleForm.cljdjg3 = this.roleForm.cljdjg
      this.roleForm.cljdjg4 = this.roleForm.cljdjg
      this.roleForm.cljdjg5 = this.roleForm.cljdjg
      this.roleForm.cljdjg6 = this.roleForm.cljdjg
      this.roleForm.qtcljdjg = this.roleForm.cljdjg
      this.roleForm.qtcljdjg2 = this.roleForm.cljdjg
      this.roleForm.qtcljdjg3 = this.roleForm.cljdjg
      this.roleForm.qtcljdjg4 = this.roleForm.cljdjg
      this.roleForm.qtcljdjg5 = this.roleForm.cljdjg
      this.roleForm.qtcljdjg6 = this.roleForm.cljdjg
      this.roleForm.cljdsj = this.roleForm.cljdjg
      this.roleForm.cljdsj2 = this.roleForm.cljdjg
      this.roleForm.cljdsj3 = this.roleForm.cljdjg
      this.roleForm.cljdsj4 = this.roleForm.cljdjg
      this.roleForm.cljdsj5 = this.roleForm.cljdjg
      this.roleForm.cljdsj6 = this.roleForm.cljdjg
      this.roleForm.yxq = this.roleForm.cljdjg
      this.roleForm.yxq2 = this.roleForm.cljdjg
      this.roleForm.yxq3 = this.roleForm.cljdjg
      this.roleForm.yxq4 = this.roleForm.cljdjg
      this.roleForm.yxq5 = this.roleForm.cljdjg
      this.roleForm.yxq6 = this.roleForm.cljdjg
      this.roleForm.qtyxq = this.roleForm.cljdjg
      this.roleForm.qtyxq2 = this.roleForm.cljdjg
      this.roleForm.qtyxq3 = this.roleForm.cljdjg
      this.roleForm.qtyxq4 = this.roleForm.cljdjg
      this.roleForm.qtyxq5 = this.roleForm.cljdjg
      this.roleForm.qtyxq6 = this.roleForm.cljdjg
      this.roleForm.jdws = this.roleForm.cljdjg
      this.roleForm.jdws2 = this.roleForm.cljdjg
      this.roleForm.jdws3 = this.roleForm.cljdjg
      this.roleForm.jdws4 = this.roleForm.cljdjg
      this.roleForm.jdws5 = this.roleForm.cljdjg
      this.roleForm.jdws6 = this.roleForm.cljdjg
      for (let item in this.roleForm) {
        if (item !== 'id' && item !== 'processId' && item !== 'authUserId' && this.roleForm[item]) {
          this.selected.push(item)
        }
      }
      console.log(this.selected)
      if (this.selected.length > 0) {
        this.isIndeterminate2 = true
      } else {
        this.isIndeterminate2 = false
      }
    },
    getRoles () {
      this.role = []
      this.isIndeterminate = false
      this.$http.get(this.$http.defaults.selectionAPI + `api/busClueReportFuncAuth/geUserFuncList2?userId=` + this.roleuser[1]).then(response => {
        if (response.data.success) {
          let roleids = response.data.result
          for (let roleid of roleids) {
            this.role.push(this.roles[roleid - 1])
          }
          this.handleCheckedChange(this.role)
        } else {
          console.log('获取失败:' + response.data.message)
          this.$message({
            message: '获取失败:' + response.data.message,
            type: 'error'
          })
        }
      })
    },
    getRoles2 () {
      this.listLoading = true
      this.$http.get(this.$http.defaults.selectionAPI + `api/busClueReportProcessAuth/getAuthByPerson?userId=` + this.roleuser[1]).then(response => {
        if (response.data.success) {
          this.$refs.multipleTable.clearSelection()
          let ids = []
          this.userRoles = response.data.result
          for (let item of this.userRoles) {
            for (let info of this.list) {
              if (item.processId === info.id) {
                ids.push(info)
              }
            }
          }
          this.toggleSelection(ids)
          this.listLoading = false
        } else {
          this.listLoading = false
          console.log('获取失败:' + response.data.message)
          this.$message({
            message: '获取失败:' + response.data.message,
            type: 'error'
          })
        }
      })
    },
    toggleSelection (rows) {
      if (rows && rows.length > 0) {
        rows.forEach(row => {
          this.$refs.multipleTable.toggleRowSelection(row)
        })
      } else {
        this.$refs.multipleTable.clearSelection()
      }
    },
    submitRoles () {
      let roleids = []
      for (let item of this.role) {
        if (this.roles.indexOf(item) !== '-1') { roleids.push(this.roles.indexOf(item) + 1) }
      }
      // if (roleids.length === 0) {
      //   this.$message({
      //     message: '至少选择一项授权',
      //     type: 'warning'
      //   })
      //   return
      // }
      let para = {authUserId: this.roleuser[1], funcIds: roleids, funcType: 2}
      this.roleSubmitLoading = true
      this.$http.post(this.$http.defaults.selectionAPI + `api/busClueReportFuncAuth/saveUserFunc`, para).then(response => {
        this.roleSubmitLoading = false
        if (response.data.success) {
          this.$message({
            message: '提交成功',
            type: 'success'
          })
          this.setrole0 = false
        } else {
          this.$message({
            message: '提交失败:' + response.data.message,
            type: 'error'
          })
        }
      })
    },
    submitRoles2 () {
      let testflag = false
      for (let item in this.roleForm) {
        if (item !== 'id' && item !== 'id' && item !== 'id' && this.roleForm[item]) {
          testflag = true
          break
        }
      }
      if (!testflag) {
        this.$message({
          message: '至少选择一个字段',
          type: 'warning'
        })
        return
      }
      let insertList = []
      let updateList = []
      let removeList = []
      if (this.settype === 2) { // 批量授权模式
        console.log('settype2')
        for (let item of this.ids) { // 遍历所有选中纪录
          let insertObj = Object.assign({}, this.roleForm)
          insertObj.authUserId = this.roleuser[1]
          insertObj.processId = item.id
          let insertOrUpdate = 'insert'
          for (let userRole of this.userRoles) {
            if (userRole.processId === item.id) {
              insertObj.id = userRole.id
              insertOrUpdate = 'update'
              break
            }
          }
          if (insertOrUpdate === 'insert') {
            insertList.push(insertObj)
          } else if (insertOrUpdate === 'update') {
            updateList.push(insertObj)
          }
        }
        for (let userRole of this.userRoles) { // 遍历当前所选被授权用户的已授权纪录
          let delflag = true
          for (let item of this.ids) { // 遍历所有选中纪录
            if (userRole.processId === item.id) {
              delflag = false
              break
            }
          }
          if (delflag) {
            removeList.push(userRole.id)
          }
        }
      } else if (this.settype === 1) {
        console.log('settype1:' + this.processId)
        let insertObj = Object.assign({}, this.roleForm)
        insertObj.authUserId = this.roleuser[1]
        insertObj.processId = this.processId
        let insertOrUpdate = 'insert'
        for (let userRole of this.userRoles) {
          if (userRole.processId === this.processId) {
            insertObj.id = userRole.id
            insertOrUpdate = 'update'
            break
          }
        }
        if (insertOrUpdate === 'insert') {
          insertList.push(insertObj)
        } else if (insertOrUpdate === 'update') {
          updateList.push(insertObj)
        }
      }
      let para = {
        insertList: insertList,
        updateList: updateList,
        removeList: removeList
      }
      this.roleSubmitLoading2 = true
      this.$http.post(this.$http.defaults.selectionAPI + `api/busClueReportProcessAuth/saveAuth`, para).then(response => {
        this.roleSubmitLoading2 = false
        if (response.data.success) {
          this.$message({
            message: '提交成功',
            type: 'success'
          })
          this.$refs.drawer.closeDrawer()
          this.getList()
        } else {
          this.$message({
            message: '提交失败:' + response.data.message,
            type: 'error'
          })
        }
      })
    },
    removeAuth () {
      let para = {
        authUserId: this.roleuser[1],
        processId: this.processId
      }
      this.removeAuthLoading2 = true
      this.$http.post(this.$http.defaults.selectionAPI + `api/busClueReportProcessAuth/removeAuth`, para).then(response => {
        this.roleSubmitLoading2 = false
        if (response.data.success) {
          this.$message({
            message: '取消授权成功',
            type: 'success'
          })
          this.$refs.drawer.closeDrawer()
          this.getList()
        } else {
          this.$message({
            message: '取消授权失败:' + response.data.message,
            type: 'error'
          })
        }
      })
    },
    username (id) {
      for (let item of this.userlist) {
        for (let user of item.children) {
          if (user.value === id) { return user.label }
        }
      }
    },
    handleCheckAllChange (val) {
      this.role = val ? this.roles : []
      this.isIndeterminate = false
    },
    handleCheckedChange (value) {
      let checkedCount = value.length
      this.checkAll = checkedCount === this.roles.length
      this.isIndeterminate = checkedCount > 0 && checkedCount < this.roles.length
    },
    setRoleType () {
      if (this.roleuser[0] === 2 || this.roleuser[0] === 3 || this.roleuser[0] === 4) {
        this.setRole = true
        this.getRoles2()
      } else {
        this.setRole = false
        this.setrole0 = true
        this.getRoles()
      }
    },
    getuserlist () {
      this.$http.get(this.$http.defaults.selectionAPI + `api/selection/auth/getUsersGroupByUnitname?self=false`).then(response => {
        if (response.data.success) {
          let i = 1
          for (let keyname in response.data.result) {
            let users = []
            for (let item of response.data.result[keyname]) {
              users.push({label: item.truename, value: item.id})
            }
            this.userlist.push({label: keyname, value: i, children: users})
            i++
          }
        } else {
          console.log('获取失败:' + response.data.message)
          this.$message({
            message: '获取失败:' + response.data.message,
            type: 'error'
          })
        }
      })
    },
    setRoleForm (obj) {
      this.roleForm = {
        id: '',
        processId: '',
        authUserId: '',
        dw: false,
        bm: false,
        xm: false,
        idcardno: false,
        xb: false,
        zw: false,
        zwcc: false,
        zywgwjwtzy: false,
        wtly: false,
        qtwtly: false,
        wtrd: false,
        lasj: false,
        lajdjg: false,
        cllx: false,
        qtcllx: false,
        clnr: false,
        cljdjg: false,
        cljdjg2: false,
        cljdjg3: false,
        cljdjg4: false,
        cljdjg5: false,
        cljdjg6: false,
        qtcljdjg: false,
        qtcljdjg2: false,
        qtcljdjg3: false,
        qtcljdjg4: false,
        qtcljdjg5: false,
        qtcljdjg6: false,
        cljdsj: false,
        cljdsj2: false,
        cljdsj3: false,
        cljdsj4: false,
        cljdsj5: false,
        cljdsj6: false,
        yxq: false,
        yxq2: false,
        yxq3: false,
        yxq4: false,
        yxq5: false,
        yxq6: false,
        qtyxq: false,
        qtyxq2: false,
        qtyxq3: false,
        qtyxq4: false,
        qtyxq5: false,
        qtyxq6: false,
        jdws: false,
        jdws2: false,
        jdws3: false,
        jdws4: false,
        jdws5: false,
        jdws6: false,
        clzxqk: false,
        remark: false
      }
      for (let item in this.roleForm) {
        if (item !== 'id' && item !== 'processId' && item !== 'authUserId' && obj && obj[item]) {
          this.roleForm[item] = true
        }
      }
      console.log('obj')
      console.log(obj)
      this.roles2change()
    },
    setAuth (id) {
      console.log('setAuthId:' + id)
      if (id) {
        this.settype = 1 // 单条记录授权
        this.processId = id
        this.drawer = true
        this.setAuthText = ''
        // 回显选定字段
        for (let item of this.userRoles) {
          if (item.processId === id) {
            this.setRoleForm(item)
            break
          } else {
            this.setRoleForm()
          }
        }
      } else {
        this.settype = 2 // 多条记录批量授权
        if (this.ids.length > 0) {
          this.drawer = true
          this.setAuthText = '（批量授权会覆盖用户之前的授权记录）'
          this.setRoleForm()
        } else {
          this.$message({
            message: '请选择至少一条记录',
            type: 'warning'
          })
        }
      }
    },
    changeAuthFlag () {
      this.authFlag ? this.authFlag = false : this.authFlag = true
    },
    handleSelectionChange (val) {
      this.ids = val
    },
    del (id) {
      this.$confirm('确认删除该记录吗?', '提示', {
        type: 'error'
      }).then(() => {
        this.$http.get(this.$http.defaults.selectionAPI + `api/busClueReportProcess/remove?id=` + id).then(response => {
          if (response.data.success === true) {
            this.$message({
              message: '删除成功',
              type: 'success'
            })
          } else {
            console.log('删除失败:' + response.data.message)
            this.$message({
              message: '删除失败:' + response.data.message,
              type: 'error'
            })
          }
          this.getList()
        })
      }).catch(() => {
      })
    },
    dialogHide (flag) {
      this.dialogVisible = false
      if (flag) {
        this.getList()
      }
    },
    addnew (flag, data) {
      this.readonly = false
      this.dialogtitle = '新增干部处理'
      if (flag) {
        console.log('通过举报新增')
        this.item = {}
        data.edittype = 'add'
        this.item = Object.assign({}, data)
      } else {
        console.log('新增空')
        this.item = {}
      }
      this.dialogVisible = true
      this.timestamp = new Date().getTime()
    },
    detail (data) {
      this.readonly = true
      this.dialogtitle = '查看干部处理详情'
      data.edittype = 'edit'
      this.item = Object.assign({}, data)
      this.dialogVisible = true
      this.timestamp = new Date().getTime()
    },
    edit (data) {
      this.readonly = false
      this.dialogtitle = '编辑干部处理'
      data.edittype = 'edit'
      this.item = Object.assign({}, data)
      this.dialogVisible = true
      this.timestamp = new Date().getTime()
    },
    exportPrj (id) {
      var _this = this
      this.$confirm('确定结束起草?', '提示', {
        type: 'success'
      }).then(() => {
        this.myloading = true
        this.$http.post(`/api/prj/finishqicao/` + id).then(function (response) {
          if (response.data.success === true) {
            _this.$message({
              message: '操作成功',
              type: 'success'
            })
          } else {
            console.log('操作失败:' + response.data.message)
            _this.$message({
              message: '操作失败:' + response.data.message,
              type: 'error'
            })
          }
          _this.myloading = false
          _this.getPrj()
        })
      })
    },
    editPrj: function (id) {
      console.log('editid:' + id)
      this.$router.push({path: '/assess/edit/' + id})
    },
    handleSizeChange (val) {
      this.changeSizeFlag = true
      this.pageNum = 1
      this.pageSize = val
      this.getList()
    },
    handleCurrentChange (val) {
      if (this.changeSizeFlag === false) {
        this.pageNum = val
        this.getList()
      }
    },
    // 查询
    search () {
      this.pageNum = 1
      this.getList()
    },
    // 排序
    sortChange: function (column, prop, order) {
      this.Sortkey = column.prop
      if (column.order === 'ascending') {
        this.Isace = 'asc'
      } else {
        this.Isace = 'desc'
      }
      this.getList()
    },
    getList () {
      let para = {
        xm: this.filters.xm,
        dw: this.filters.dw,
        wtly: this.filters.wtly && this.filters.wtly !== '' ? this.filters.wtly : null,
        cllx: this.filters.cllx && this.filters.cllx.length > 0 ? this.filters.cllx[this.filters.cllx.length - 1] : null,
        cljdjg: this.filters.cljdjg && this.filters.cljdjg !== '' ? this.filters.cljdjg : null,
        cljdsj: this.filters.cljdsj ? this.filters.cljdsj[0] : null,
        cljdsj2: this.filters.cljdsj ? this.filters.cljdsj[1] : null,
        yxq: this.filters.yxq && this.filters.yxq !== '' ? this.filters.yxq : null,
        pageNum: this.pageNum,
        pageSize: this.pageSize,
        sortField: this.Sortkey,
        sortOrder: this.Isace
      }
      this.listLoading = true
      // var personParams = { Page: 0, Pagenum: 20, Personname: '', Unitkey: '', Sortkey: '', Isace: true, timestamp: new Date().getTime() }
      this.$http
        .post(this.$http.defaults.selectionAPI + `api/busClueReportProcess/query`, para)
        .then(response => {
          if (response.data.success) {
            this.listLoading = false
            this.list = response.data.result.records
            this.totalnum = response.data.result.total
            this.changeSizeFlag = false
            if ((this.roleuser[0] === 2 || this.roleuser[0] === 3 || this.roleuser[0] === 4) && this.setRole) {
              this.getRoles2()
            }
          } else {
            this.$message({
              message: '获取失败:' + response.data.message,
              type: 'error'
            })
          }
        })
        .catch(error => {
          this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
        })
    },
    delPrj (id) {
      var _this = this
      this.$confirm('确认删除该记录吗?', '提示', {
        type: 'error'
      }).then(() => {
        this.$http.post(`/api/prj/remove/` + id).then(function (response) {
          if (response.data.success === true) {
            _this.$message({
              message: '删除成功',
              type: 'success'
            })
          } else {
            console.log('删除失败:' + response.data.message)
            _this.$message({
              message: '删除失败:' + response.data.message,
              type: 'error'
            })
          }
          _this.getPrj()
        })
      }).catch(() => {
      })
    },
    querySearch (queryString, cb) {
      return this.getunits(this, queryString, cb)
    },
    getunits (self, queryString, cb) {
      let para = {
        unitname: queryString
      }
      let newArr = []
      self.$http
        .post(`/api/prj/searchunit/`, para)
        .then(response => {
          if (response.data) {
            console.log('获取成功')
            var results = response.data
            results.forEach(function (item) {
              let obj = {'value': item}
              newArr.push(obj)
            })
          }
          cb(newArr)
        })
        .catch(function (error) {
          console.log(error)
        })
    },
    tableresize (obj) {
      var clientHeight = 0
      if (document.body.clientHeight && document.documentElement.clientHeight) {
        clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      } else {
        clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      }
      let myheight = 385
      if (this.moreshow) {
        myheight = 385
      } else {
        myheight = 322
      }
      obj.$nextTick(function () {
        obj.tableHeight = clientHeight - myheight
      })
    }
  },
  mounted () {
    this.myyear = new Date().getFullYear()
    this.userRoles0 = JSON.parse(localStorage.getItem('Roles'))
    let data = this.$route.params.data
    if (data) {
      this.addnew(true, data)
    }
    this.getAllDics()
    this.getuserlist()
    this.getList()
    if (this.inRoles('ROLE_jubao') || this.inRoles('ROLE_admin')) {
      this.roleAdmin = true
      this.roleShow = true
      this.roleEdit = true
      this.roleChart = true
      this.roleExport = true
    } else {
      this.roleAdmin = false
      this.geCurrUserRole()
    }
    this.getYearList()
    this.tableresize(this)
    window.onresize = () => {
      this.tableresize(this)
    }
  }
}
</script>
<style>
#cluereport .el-drawer__wrapper{
  width: 100%;
  height: 100%;
  position: fixed !important;
  overflow: hidden;
}
  .wboxd .el-table th{
    font-weight: normal;
    background-image: linear-gradient(to bottom , #f8f8f8, #efefef);
  }
  .wboxd .el-table td, .el-table th{
    padding:0;
    font-size:var(--size14) !important;
    line-height: 20px;
    font-family: '宋体'
  }
  .tableth{
    background-image: linear-gradient(to bottom , #f8f8f8, #efefef);
    height:33px;
  }
  #testlist .wboxs{
    height:45px;
    padding-top:10px;
  }
  #cluereport .el-table td{
    border-right: 1px solid #95B8E7;
    border-bottom: 1px solid #95B8E7;
  }
</style>
<style scoped>
  #cluereport .el-button{
    color:#fff !important;
  }
  #cluereport h1{
    font-size:var(--size16) !important;
    font-weight: bolder;
    height: 30px;
    border-bottom: 1px solid #95B8E7;
    font-family: '宋体';
    line-height: 30px;
    color: #000;
    padding-left:10px;
    background-image: linear-gradient(to bottom , #EEF4FF, #E0ECFF);
    margin:0;
  }
  .el-pagination{
    float: left;
    padding:7px 10px;
  }
  #cluereport .wboxs{
    width: 100%;
    background: #fff;
    border: 1px solid #95B8E7;
    margin:0 10px;
    overflow: hidden;
    padding:0;
  }
  .wboxd{
    padding:0;
    width: calc(100% - 0px);
    background: #fff;
    border: 1px solid #95B8E7;
    margin:0 10px;
    overflow: hidden;
  }
</style>
